﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using GIMS.Def.Arguments;
using GIMS.Def.Flags;
using GIMS.Def.Settings;

namespace GIMS.Def.Operators
{
    public class CanvasOperator : Operator
    {
        private SizeSetting sizeSetting;
        
        public CanvasOperator()
        {
            name = "Canvas";
            description = "Creates an image with a specific color";
            instruction = "canvas:";
            iconPath = @"Images\canvas.png";
            argument = new ColorArgument();
            possiblePrograms = Program.convert;
            position = Position.First;
            sizeSetting = new SizeSetting();
            sizeSetting.Description = "Size of the created image";
            settings = new List<Setting> {sizeSetting};

            argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            sizeSetting.Argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            sizeSetting.PropertyChanged += new PropertyChangedEventHandler(OnSettingChanged);

            ((ColorArgument) argument).Color = Color.White;
            sizeSetting.Active = true;
            GeometryArgument sizeArgument = (GeometryArgument) sizeSetting.Argument;
            sizeArgument.Height = 100;
            sizeArgument.Width = 100;
        }

        /// <summary>
        /// No whitespace between instruction and argument
        /// </summary>
        /// <returns></returns>
        protected override string CreateOperatorScript()
        {
            return string.Concat(instruction, argument.CreateScriptPart());
        }
    }
}
